home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-09-04 | 1.6 KB | 35 lines | [TEXT/CCL ] |
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;; Copyright 1989, 1990 by Ruben Kleiman for Apple Computer, Inc.
- ;;; Advanced Technology Group
- ;;;
-
- ;;;
- ;;; MultiFinder friendly hack.
- ;;; This hack ensures that Lisp code that runs while Macintosh Allegro Common Lisp
- ;;; is in the background executes in a MultiFinder friendly manner.
- ;;; This hack works in MACL 1.3. The main effect is to reduce the overhead
- ;;; when your code is executing in the background, ensuring maximum
- ;;; time for the foreground task.
-
- ;;;
- ;;; The usage is: (in-multifinder-background <form>*)
- ;;;
-
- (defparameter $CurrentA5 #x904) ; A5 GLOBAL ADDRESS
- (defparameter *inest-ptr* (%inc-ptr (%get-ptr $currentA5) #x-106)) ; A5 OFFSET TO CURRENT INTERRUPT LEVEL
-
- ;;; WRAP AROUND FOR CODE THAT YOU WANT TO EVALUATE WHILE IN MACL
- ;;; IS IN THE MULTIFINDER BACKGROUND: THIS WILL MAKE MACL MULTIFINDER FRIENDLY
- (defmacro in-multifinder-background (&body body)
- (let ((old-level (gensym)) ; TO RESET OLD INTERRUPT LEVEL
- (result (gensym))) ; RESULT OF EVALUATING BODY
- `(let ((,old-level (%get-signed-word *inest-ptr*)) ; GET CURRENT INTERRUPT LEVEL
- ,result
- (*processing-events* nil)) ; DON'T HANDLE ANY OTHER EVENTS!
- (unwind-protect
- (progn
- (%put-word *inest-ptr* 0) ; SET NEW INTERRUPT LEVEL
- (setq ,result ,(cons 'PROGN body))) ; EVAL BODY
- (%put-word *inest-ptr* ,old-level) ; RESET TO OLD INTERRUPT LEVEL
- ,result)))) ; RETURN RESULT
-